#

| Chapter 40 Delayed Execution |

## 40.13 Adding crontab Entries

Most recent versions of UNIX have a special command for maintaining the crontab file. To create a new crontab file, create a file containing the desired crontab entries. Then run the crontab command to install the file in the cron spool area. For example, if user chavez executes the command below, the file mycron will be installed as /usr/spool/cron/crontabs/chavez:

>     $ crontab mycron

If chavez had previously installed crontab entries, they will be replaced by those in mycron; thus, any current entries that chavez wishes to keep must also be present in mycron.

The -l option to crontab lists the current crontab entries, and redirecting its output to a file will allow them to be captured and edited:

>     $ crontab -l >mycron
>     $ vi mycron
>     $ crontab mycron

The -r option will remove all current crontab entries. Under SunOS, crontab has an additional -e option that lets you directly edit your current crontab entries in a single step (see article 40.15 for a script like that).

On BSD-based UNIX implementations, there is no separate crontab command, nor does each user get a personal crontab file. BSD does distinguish between "global" crontab entries (in /usr/lib/crontab) and "local" entries (in /usr/lib/crontab.local)-however, you have to edit these files directly, which will probably require you to become superuser. It's a good idea to collect personal and site-specific crontab entries in the crontab.local file.

- AF from O'Reilly & Associates' Essential System Administration

40.12 Periodic Program Execution: The cron Facility |  | 40.14 Including Standard Input Within a cron Entry